package com.fhz.mvvmshopjava.ui.index;

import android.os.Bundle;
import android.view.Gravity;
import android.widget.FrameLayout;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.fragment.app.Fragment;

import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.BottomNavigationItem;
import com.ashokvarma.bottomnavigation.TextBadgeItem;
import com.fhz.mvvmshopjava.R;
import com.fhz.mvvmshopjava.databinding.ActivityIndexBinding;
import com.fhz.mvvmshopjava.ui.classify.ClassifyFragment;
import com.fhz.mvvmshopjava.ui.goods.GoodsFragment;
import com.fhz.mvvmshopjava.ui.home.HomeFragment;
import com.fhz.mvvmshopjava.ui.mine.MineFragment;
import com.fhz.mvvmshopjava.utils.UserManager;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import dagger.hilt.android.AndroidEntryPoint;

/**
 * 不做具体功能,用来盛放fragment
 */
@AndroidEntryPoint
public class IndexActivity extends AppCompatActivity {


    private ActivityIndexBinding binding;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         binding = DataBindingUtil.setContentView(this, R.layout.activity_index);

        List<Fragment> list = new ArrayList<>();
        list.add(new HomeFragment());
        list.add(new ClassifyFragment());
        list.add(new GoodsFragment());
        list.add(new MineFragment());


        binding.indexViewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager(),list));

        TextBadgeItem numberBadgeItem = new TextBadgeItem();
        numberBadgeItem.setText("9") //显示的文本
                .setBackgroundColor("#FF0000") //背景色
                .setTextColor("#FFFFFF") //文本颜色
                .setBorderColor("#000000") //border颜色
                .setBorderWidth(1) //border宽度px
                .setAnimationDuration(30) //隐藏和展示的动画速度，单位毫秒,和setHideOnSelect一起使用
                .setGravity(Gravity.RIGHT|Gravity.TOP) //位置，默认右上角
                .setHideOnSelect(true); //true：当选中状态时消失，非选中状态显示,moren false
        binding.bottomNavigationBar
                .addItem(new BottomNavigationItem(R.mipmap.ic_launcher, "首页"))
                .addItem(new BottomNavigationItem(R.mipmap.ic_launcher, "分类"))
                .addItem(new BottomNavigationItem(R.mipmap.ic_launcher, "购物车"))
                .addItem(new BottomNavigationItem(R.mipmap.ic_launcher, "我的"))
                .initialise();//所有的设置需在调用该方法前完成

        binding.bottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener(){
            @Override
            public void onTabSelected(int position) {
                //未选中->选中
                binding.indexViewPager.setCurrentItem(position);
            }
            @Override
            public void onTabUnselected(int position) {
                //选中->未选中
            }
            @Override
            public void onTabReselected(int position) {
                //选中->选中
            }
        });


    }


}